{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "16d2f215-37cf-4ba0-b41b-bb9c701b6c3a",
   "metadata": {},
   "source": [
    "# Python的基本结构类型\n",
    "\n",
    "## "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6af43c0b-4600-4728-a3b1-c0227447c442",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
     ]
    }
   ],
   "source": [
    "a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cd11ab89-4805-47fa-980a-11a9346ef229",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "916fc37b-8843-4cba-a4c0-5385fdc2d3da",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in range(10):\n",
    "    b.append(i)          \n",
    "b.reverse()\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cd5ac027-5bf0-41f5-87ac-f8762aeeb9ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in range(9,-1,-1):\n",
    "    b.append(i)          \n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c4f2fa90-5f28-4930-862d-d84732467ac7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in range(10):\n",
    "    b.append(9-i)          \n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e7873a6e-1f05-443d-8111-f3bb2870ebd2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4.5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b = []\n",
    "for i in range(10):\n",
    "    b.append(9-i)  \n",
    "b.insert(5,4.5)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "73997b71-7860-4e59-9480-d9d53a5053ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "17d322c0-c293-43d1-9cb1-b9eb97eee8b7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[322, 323]\n"
     ]
    }
   ],
   "source": [
    "a = list(range(1,1001))\n",
    "print(a[321:323])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2cebee3f-2a10-45bd-9736-a465cf34d3d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = a*2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b36fa742-8f22-4a22-ae4d-b8091ea4765a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5}\n"
     ]
    }
   ],
   "source": [
    "a = {1,2,3,4,5}\n",
    "a.add(2)\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3efeae25-f235-4f96-91db-d9201b598bd0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词（输入end结束）:  BLUE\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "蓝色\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词（输入end结束）:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不知道\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词（输入end结束）:  Blue\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "蓝色\n"
     ]
    }
   ],
   "source": [
    "dictionary = {\n",
    "    \"apple\": \"苹果\",\n",
    "    \"banana\": \"香蕉\",\n",
    "    \"orange\": \"橙子\",\n",
    "    \"grape\": \"葡萄\",\n",
    "    \"strawberry\": \"草莓\",\n",
    "    \"red\": \"红色\",\n",
    "    \"blue\": \"蓝色\",\n",
    "    \"green\": \"绿色\",\n",
    "    \"yellow\": \"黄色\",\n",
    "    \"purple\": \"紫色\",\n",
    "}\n",
    "\n",
    "\n",
    "dictionary.update({\n",
    "    \"苹果\": \"apple\",\n",
    "    \"香蕉\": \"banana\",\n",
    "    \"橙子\": \"orange\",\n",
    "    \"葡萄\": \"grape\",\n",
    "    \"草莓\": \"strawberry\",\n",
    "    \"红色\": \"red\",\n",
    "    \"蓝色\": \"blue\",\n",
    "    \"绿色\": \"green\",\n",
    "    \"黄色\": \"yellow\",\n",
    "    \"紫色\": \"purple\",\n",
    "})\n",
    "\n",
    "while True:\n",
    "    user_input = input(\"请输入单词（输入end结束）: \").strip().lower()\n",
    "    \n",
    "    if user_input == \"end\":\n",
    "        break\n",
    "    \n",
    "    if user_input in dictionary:\n",
    "        print(dictionary[user_input])\n",
    "    else:\n",
    "        print(\"不知道\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a714b8d-6d5c-44f0-957e-c7b0448ef364",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
